package com.aaa.ssm.servie.impl;

import com.aaa.ssm.entity.Student;
import com.aaa.ssm.mapper.StudentMapper;
import com.aaa.ssm.query.StudentQuery;
import com.aaa.ssm.servie.StudentService;
import com.aaa.ssm.vo.StudentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper  mapper;

    @Override
    public int add(StudentVO stu) {
        return mapper.add(stu);
    }

    @Override
    public Map<String, Object> listAllStudent(StudentQuery query) {
        //1 查询当前页的信息
        List<Student> students = mapper.listCurrentPageData(query);
        // 2查询总数量
        Long totalCount = mapper.getTotalCount(query);

        HashMap<String, Object> map = new HashMap<>();
        map.put("currentData",students);
        map.put("total",totalCount);

        return map;
    }

}
